package Event;

import javax.swing.*;
import java.awt.*;

public class WindowEventAction extends JFrame {
    JTextField inputText;
    JTextArea textArea;
    JButton button;
    MyCommandListner listner;
    public WindowEventAction(){
        init();
        setVisible(true);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    }
    void init(){
        setLayout(new FlowLayout());
        inputText=new JTextField(10);
        button =new JButton("确定");
        textArea=new JTextArea(9,30);
        add(inputText);
        add(button);
        add(textArea);
        add(new JScrollPane(textArea)); //滚动条

    }

    void setMyCommandListner(MyCommandListner listner){
        this.listner=listner;
        listner.setJTextField(inputText);
        listner.setJTextArea(textArea);
        inputText.addActionListener(listner);
        button.addActionListener(listner);

    }

}
